package com.example.lenovo.demo.presenter.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.lenovo.demo.R;
import com.example.lenovo.demo.model.databean.StrategyBean;

import java.util.List;

/**
 * Created by Lenovo on 2017/1/14.
 */

public class StrategyAcLvGvAdapter extends BaseAdapter {
    private List<StrategyBean.PagesBean> data;
    private Context context;

    public StrategyAcLvGvAdapter(List<StrategyBean.PagesBean> pages, Context context) {
        this.data = pages;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        TextView textView;
        if(view==null){
            view= LayoutInflater.from(context).inflate(R.layout.strategyac_lv_gvitem,viewGroup,false);
            textView= (TextView) view.findViewById(R.id.strategyAc_Lv_Gvitem_tv);
            view.setTag(textView);
        }else {
            textView= (TextView) view.getTag();
        }
        textView.setText(data.get(i).getTitle());
        return view;
    }
}
